package com.ruoyi.web.controller.tuike;

import com.ruoyi.tiktok.domain.TaskVideoRelation;
import com.ruoyi.tiktok.service.TaskVideoRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/relations")
public class TaskVideoRelationController {
    @Autowired
    private TaskVideoRelationService relationService;

    @PostMapping
    public void createRelation(@RequestBody TaskVideoRelation relation) {
        relationService.createRelation(relation);
    }

    /**
     *  不想暴露delete 接口
     * @param id
     */
    //@DeleteMapping("/{id}")
    public void deleteRelationById(@PathVariable int id) {
        relationService.deleteRelationById(id);
    }

    @GetMapping
    public TaskVideoRelation getRelation(@RequestParam String taskId, @RequestParam String videoId) {
        return relationService.getRelation(taskId, videoId);
    }

    @GetMapping("/task/{taskId}")
    public List<TaskVideoRelation> getRelationsByTaskId(@PathVariable String taskId) {
        return relationService.getRelationsByTaskId(taskId);
    }
}

